<?php
/**
 * Smarty plugin
 * @package Smarty
 * @subpackage plugins
 */

/**
 * Include the {@link shared.make_timestamp.php} plugin
 */

/**
 * Smarty date_format modifier plugin
 *
 * Type:     modifier<br>
 * Name:     date_format<br>
 * Purpose:  format datestamps via strftime<br>
 * Input:<br>
 *         - string: input date string
 *         - format: strftime format for output
 *         - default_date: default date if $string is empty
 * @link http://smarty.php.net/manual/en/language.modifier.date.format.php
 *          date_format (Smarty online manual)
 * @author   Monte Ohrt <monte at ohrt dot com>
 * @param string
 * @param string
 * @param string
 * @return string|void
 * @uses smarty_make_timestamp()
 */
function smarty_function_date_thai_format($params, &$smarty) 
{

    $datetime   = $params['date'];
    $usedate = $params['usedate'];
    $usetime = $params['usetime'];

    if ($datetime != '') {
        $dateTimeSplit = split(" " ,$datetime );

        $dateSplit =  split("-" ,$dateTimeSplit[0]);

        if($dateSplit[1]==1){
          $dateSplit[1] = "มกราคม";
        }else if($dateSplit[1]==2){
          $dateSplit[1] = "กุมภาพันธ์";
        }else if($dateSplit[1]==3){
          $dateSplit[1] = "มีนาคม";
        }else if($dateSplit[1]==4){
          $dateSplit[1] = "เมษายน";
        }else if($dateSplit[1]==5){
          $dateSplit[1] = "พฤษภาคม";
        }else if($dateSplit[1]==6){
          $dateSplit[1] = "มิถุนายน";
        }else if($dateSplit[1]==7){
          $dateSplit[1] = "กรกฎาคม";
        }else if($dateSplit[1]==8){
          $dateSplit[1] = "สิงหาคม";
        }else if($dateSplit[1]==9){
          $dateSplit[1] = "กันยายน";
        }else if($dateSplit[1]==10){
          $dateSplit[1] = "ตุลาคม";
        }else if($dateSplit[1]==11){
          $dateSplit[1] = "พฤศจิกายน";
        }else if($dateSplit[1]==12){
          $dateSplit[1] = "ธันวาคม";
        }

        if($usedate  == true && $usetime == true ){
          echo $dateSplit[2]."&nbsp;".$dateSplit[1]."&nbsp;".($dateSplit[0]+543)."<BR>เวลา&nbsp;". $dateTimeSplit[1];
        }else if($usedate  == true ){
          echo $dateSplit[2]."&nbsp;".$dateSplit[1]."&nbsp;".($dateSplit[0]+543);
        }
    } else {
        echo "";
    }

}

/* vim: set expandtab: */

?>
